package com.hiray.demos.entry

import android.content.Intent
import androidx.databinding.DataBindingUtil
import android.os.Bundle
import androidx.core.app.ActivityCompat
import androidx.core.app.ActivityOptionsCompat
import androidx.appcompat.app.AppCompatActivity
import androidx.recyclerview.widget.LinearLayoutManager
import android.view.View
import com.hiray.demos.R
import com.hiray.demos.databinding.ActivityCrossShareTransitionBinding
import com.hiray.demos.glue.CrossAdapter
import com.hiray.demos.model.ItemModel
import kotlinx.android.synthetic.main.activity_cross_share_transition.*

class CrossActivityShareTransitionActivity : AppCompatActivity(), CrossAdapter.OnItemClickListener {

    override fun onItemClick(view: View) {
        val opt = ActivityOptionsCompat.makeSceneTransitionAnimation(this@CrossActivityShareTransitionActivity, view,getString(R.string.transition_img_name)).toBundle()
        val intent = Intent(this@CrossActivityShareTransitionActivity, CrossActivityShareDetailActivity::class.java)
        ActivityCompat.startActivity(this@CrossActivityShareTransitionActivity, intent, opt)
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_cross_share_transition)
        /* var binding =*/ DataBindingUtil.setContentView<ActivityCrossShareTransitionBinding>(this, R.layout.activity_cross_share_transition)
        val crossAdapter = CrossAdapter(this@CrossActivityShareTransitionActivity)
        crossAdapter.data = MutableList(50, {
            ItemModel()
        })
        recyclerview.adapter = crossAdapter

        recyclerview.layoutManager = androidx.recyclerview.widget.LinearLayoutManager(this, androidx.recyclerview.widget.LinearLayoutManager.VERTICAL, false)
    }

}
